﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MS.InformationManagement.Presenter.Support;

namespace MS.InformationManagement.Presenter.SolicitudesPrestamo
{
    public class SolicitudesPrestamoPresenter : BasePresenter<ISolicitudesPrestamoView>
    {
        #region Constructors

        public SolicitudesPrestamoPresenter(ISolicitudesPrestamoView view) : base(view) { }

        #endregion

        #region Public Methods

        public void LoadSolicitudesEnviadas()
        {
            int totalRecords;
            View.listaSolicitud = MS.InformationManagement.BLL.SolicitudesPrestamo.SolicitudesPrestamo.ObtenerMisSolicitudesPrestamoEnviadas(View.GuidCurrentList, View.PageIndex, View.PageSize, out totalRecords);
            View.TotalRecords = totalRecords;
            View.Show();
        }

        public void LoadSolicitudesRecibidas()
        {
            int totalRecords;
            View.listaSolicitud = MS.InformationManagement.BLL.SolicitudesPrestamo.SolicitudesPrestamo.ObtenerMisSolicitudesPrestamoRecibidas(View.GuidCurrentList, View.PageIndex, View.PageSize, out totalRecords);
            View.TotalRecords = totalRecords;
            View.Show();
        }

        public void CargarPrestamos()
        {
            int totalRecords;
            View.listaSolicitud = MS.InformationManagement.BLL.SolicitudesPrestamo.SolicitudesPrestamo.ObtenerPrestamos(View.GuidCurrentList);
            View.listaSolicitudPrestados = MS.InformationManagement.BLL.SolicitudesPrestamo.SolicitudesPrestamo.ObtenerPrestados(View.GuidCurrentList);
            View.Show();
        }

        public void CargarDevoluciones()
        {
            int totalRecords;
            View.listaSolicitud = MS.InformationManagement.BLL.SolicitudesPrestamo.SolicitudesPrestamo.ObtenerDevoluciones(View.GuidCurrentList, View.PageIndex, View.PageSize, out totalRecords);
            View.TotalRecords = totalRecords;
            View.Show();
        }

        public void CancelarSolicitud()
        {
            View.resultEliminarSolicitud = MS.InformationManagement.BLL.SolicitudesPrestamo.SolicitudesPrestamo.cancelarSolicitud(View.idSolicitud);
            View.resultCancelarSolicitud();
        }

        public void DevolverPrestamo()
        {
            View.resultEliminarSolicitud = MS.InformationManagement.BLL.SolicitudesPrestamo.SolicitudesPrestamo.DevolverRadicado(View.idSolicitud);
            View.resultCancelarSolicitud();
        }

        #endregion
    }
}
